package com.wwk.phone.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * @author 王文凯
 * @create 2022/1/25,23:43
 */
@Configuration
@EnableOpenApi
public class SwaggerConfig {


    //配置了swagger的Docket 的Bean实例
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo()) //接管了原来的默认配置
                .select() // 让他只扫描controller包下的控制器
                .apis(RequestHandlerSelectors.basePackage("com.wwk.phone.controller"))
                .build();
    }

    //配置Swagger信息 = apiInfo
    private ApiInfo apiInfo() {

        Contact contact = new Contact("王文凯", "http://localhost:8080/hello", "1565308101@qq.com");

        return new ApiInfo(
                "Pluto的SwaggerAPI文档",
                "年轻人不讲武德",
                "1.0",
                "http://localhost:8080/hello",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList<>());
    }

}
